export default class ball extends Laya.Script {
    // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    owner=this.owner as Laya.Sprite
    rig=null;
    iszuotai=false;
    isyoutai=false;
    isstart=false;

    constructor() { super(); }

    onAwake(){

        this.rig=this.owner.getComponent(Laya.RigidBody)
        Laya.stage.on("zuotai",this,function(){this.iszuotai=true})
        Laya.stage.on("youtai",this,function(){this.isyoutai=true})
        Laya.stage.on("start",this,this.start)
    }
    start(){
        this.owner.pos(360,384)
        this.rig.type="dynamic"
    }
    onTriggerEnter(other){
        if(other.label=="zuoban"){
            if(this.iszuotai){
            this.rig.linearVelocity={x:this.owner.x,y:-100}
            this.iszuotai=false;   
            }
        }
        if(other.label=="youban"){
            if(this.isyoutai){
            this.rig.linearVelocity={x:this.owner.x,y:-100}
            this.isyoutai=false;   
            }
        }
        if(other.label=="bottom"){
            Laya.stage.event("over");
            this.rig.type="static"
        }
        if(other.label=="5"){
            Laya.stage.event("Addscre",5);
        }
        if(other.label=="10"){
            Laya.stage.event("Addscre",10);
        }
        if(other.label=="20"){
            Laya.stage.event("Addscre",20);
        }
    }
}